$(document).ready(function(){







    //头部样式变换
    scroll_head();
    function scroll_head(){
        // console.log($(window).width());
        var head = $(".head");
            $(window).scroll(function () {
                if ($(window).scrollTop() >= 50) {
                    head.addClass("head_down");
                    head.find(".logo img").attr("src","img/logo_down.png");
                } else {
                    head.removeClass("head_down");
                    head.find(".logo img").attr("src","img/logo.png")
                }
            });
    }

    //暂停开始banner下的video
    play_stop_video();
    function play_stop_video() {
        var banner =$('.banner');
        var video = $("#video1");
        $(window).scroll(function () {

            if ($(window).scrollTop() >= banner.innerHeight()) {
                if(video.hasClass("play")){
                    video.removeClass('play');
                    video.addClass('pause');
                    video.trigger('pause');
                }
            }else{

                if(video.hasClass("pause")){
                    video.removeClass('pause');
                    video.addClass('play');
                    video.trigger('play');
                }
            }

        });
    }

    //team左滑动
    scroll_team();
    function scroll_team() {
        var scroll=$(".team_scroll");
        var img=$(".team_img");
        var img_box=$(".team_img_box");
        img.find("img").load(function () {
            var win_width=$(window).width();
            var img_width=img.find("img").width();
            //未防止发烧友超宽的显示器，把浏览器宽度除以图片宽度的倍数来增加图片，使图片始终可以滚动
            var num=win_width/img_width;
            if(num>1){
                Math.ceil(win_width/img_width);
                // console.log(num);
                for(var i=0;i<num;i++){
                    img.append(img.html());
                }
            }
            img_box.append(img_box.html());

            setInterval(function () {

                if(scroll.scrollLeft()>=img.width()){
                    scroll.scrollLeft(0);
                }else{
                    scroll.scrollLeft(scroll.scrollLeft()+1);
                }

            },100);

            // console.log(img.find("img").width());
            // console.log($(window).width());
            // console.log($(window).innerWidth());
        });
    }




    //index team
    index_team();
    function index_team() {
        if($(".team").length){
            // console.log(1);
            var Swiper_team = new Swiper('.swiper_team', {
                lazy: true,
                loop : true,
                autoplay: {
                    delay: 3000,//3秒切换一次
                },
                // slidesPerView: 12,
                centeredSlides: true,
                breakpoints: {
                    320: {
                        slidesPerView: 5,
                    },
                    768: {
                        slidesPerView: 10,
                    },
                    1024: {
                        slidesPerView: 12,
                    },
                },
                on: {
                    transitionStart: function(){
                        var active=$(".team .swiper-slide-active");
                        var active_img=active.find(".team_item img");
                        $(".swiper-slide").find(".team_item img").css({'height':'100%','z-index':'0','border-radius': '0'});


                        if($(window).innerWidth()>1200){
                            active_img.css({'height':'calc(100% + 110px)','z-index':'1000','border-radius': '5px'});
                            active.next().find(".team_item img").css({'height':'calc(100% + 80px)','z-index':'900','border-radius': '5px'});
                            active.next().next().find(".team_item img").css({'height':'calc(100% + 60px)','z-index':'800','border-radius': '5px'});
                            active.next().next().next().find(".team_item img").css({'height':'calc(100% + 40px)','z-index':'700','border-radius': '5px'});
                            active.next().next().next().next().find(".team_item img").css({'height':'calc(100% + 20px)','z-index':'600','border-radius': '5px'});
                            active.next().next().next().next().next().find(".team_item img").css({'height':'calc(100% + 15px)','z-index':'500','border-radius': '5px'});
                            active.next().next().next().next().next().next().find(".team_item img").css({'height':'calc(100% + 10px)','z-index':'400','border-radius': '5px'});
                            active.next().next().next().next().next().next().next().find(".team_item img").css({'height':'calc(100% + 5px)','z-index':'300','border-radius': '5px'});

                            active.prev().find(".team_item img").css({'height':'calc(100% + 80px)','z-index':'900','border-radius': '5px'});
                            active.prev().prev().find(".team_item img").css({'height':'calc(100% + 60px)','z-index':'800','border-radius': '5px'});
                            active.prev().prev().prev().find(".team_item img").css({'height':'calc(100% + 40px)','z-index':'700','border-radius': '5px'});
                            active.prev().prev().prev().prev().find(".team_item img").css({'height':'calc(100% + 20px)','z-index':'600','border-radius': '5px'});
                            active.prev().prev().prev().prev().prev().find(".team_item img").css({'height':'calc(100% + 15px)','z-index':'500','border-radius': '5px'});
                            active.prev().prev().prev().prev().prev().prev().find(".team_item img").css({'height':'calc(100% + 10px)','z-index':'400','border-radius': '5px'});
                            active.prev().prev().prev().prev().prev().prev().prev().find(".team_item img").css({'height':'calc(100% + 5px)','z-index':'300','border-radius': '5px'});

                        }else{
                            active_img.css({'height':'calc(100% + 50px)','z-index':'1000','border-radius': '5px'});
                            active.next().find(".team_item img").css({'height':'calc(100% + 30px)','z-index':'900','border-radius': '5px'});
                            active.next().next().find(".team_item img").css({'height':'calc(100% + 10px)','z-index':'800','border-radius': '5px'});

                            active.prev().find(".team_item img").css({'height':'calc(100% + 30px)','z-index':'900','border-radius': '5px'});
                            active.prev().prev().find(".team_item img").css({'height':'calc(100% + 10px)','z-index':'800','border-radius': '5px'});
                        }

                        $(".team_info").html(active.find(".team_item a").attr("data-info"));
                    },
                },
            });

            //鼠标覆盖停止自动切换
            Swiper_team.el.onmouseover = function(){
                Swiper_team.autoplay.stop();
            };

            //鼠标离开开始自动切换
            Swiper_team.el.onmouseout = function(){
                Swiper_team.autoplay.start();
            };
        }
    }
});
